//
//  YLARightCell.swift
//  Your Lover AI
//
//  Created by 阿忠 on 2024/7/1.
//

import Foundation
import UIKit

class YLARightCell: UITableViewCell {
    
    //头像
    lazy var iconImg: UIImageView = {
        let image = UIImageView(image: UIImage(named: ""))
//        image.layer.cornerRadius = 21.5
//        image.layer.masksToBounds = true
        return image
    }()
    
    //时间
    lazy var timeLab: UILabel = {
        let lab = UILabel()
        lab.text = "02 07 18:00"
        lab.textColor = .white
        lab.font = UIFont.systemFont(ofSize: 12)
        lab.textAlignment = .right
        lab.numberOfLines = 0
        return lab
    }()
    
    lazy var topVc: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(hex: "8280FB")
        view.layer.cornerRadius = 5
        view.layer.masksToBounds = true
        return view
    }()
    
    lazy var bobVc: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(hex: "8280FB")
        view.layer.cornerRadius = 5
        view.layer.masksToBounds = true
        return view
    }()
    
    lazy var leftVc: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(hex: "8280FB")
        view.layer.cornerRadius = 5
        view.layer.masksToBounds = true
        return view
    }()
    
    lazy var rightVc: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(hex: "8280FB")
        view.layer.cornerRadius = 5
        view.layer.masksToBounds = true
        return view
    }()

    //内容
    lazy var contentLab: UILabel = {
        let lab = UILabel()
        lab.text = "Intimidating yet intriguing professor, often spotted engr…"
        lab.backgroundColor = UIColor(hex: "8280FB")
        lab.textColor = .white
        lab.font = UIFont.systemFont(ofSize: 15)
        lab.textAlignment = .center
        lab.numberOfLines = 0
//        lab.layer.cornerRadius = 10
//        lab.layer.masksToBounds = true
        return lab
    }()
    
    //外围
    lazy var sideVc: UIView = {
        let view = UIView()
        view.backgroundColor = .clear
        view.layer.cornerRadius = 15
        view.layer.masksToBounds = true
        view.layer.borderWidth = 12
        view.layer.borderColor = UIColor(hex: "8280FB").cgColor
        return view
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        contentView.addSubview(timeLab)
        contentView.addSubview(iconImg)
        contentView.addSubview(topVc)
        contentView.addSubview(bobVc)
        contentView.addSubview(contentLab)
        initUI()
    }

    
    func initUI()
    {
        
        timeLab.snp.makeConstraints { make in
            make.right.equalTo(-32)
            make.top.equalTo(25)
            make.height.equalTo(9.17)
            make.width.equalTo(70)
        }
        
        iconImg.snp.makeConstraints { make in
            make.right.equalTo(timeLab.snp.left).offset(-10)
            make.centerY.equalTo(timeLab)
            make.width.height.equalTo(16)
        }
        
        contentLab.snp.makeConstraints { make in
//            make.top.equalTo(timeLab.snp.bottom).offset(9)
//            make.bottom.equalToSuperview()
            make.width.lessThanOrEqualTo(234)
//            make.height.lessThanOrEqualTo(45)
            make.right.equalTo(-43)
        }
        
        contentView.addSubview(leftVc)
        leftVc.snp.makeConstraints { make in
            make.centerY.equalTo(contentLab)
            make.left.equalTo(contentLab.snp.left).offset(-10)
            make.height.equalTo(contentLab.snp.height).offset(20)
            make.width.equalTo(10)
        }
        
        contentView.addSubview(rightVc)
        rightVc.snp.makeConstraints { make in
            make.centerY.equalTo(contentLab)
            make.left.equalTo(contentLab.snp.right).offset(0)
            make.height.equalTo(contentLab.snp.height).offset(20)
            make.width.equalTo(10)
        }
        
        
        topVc.snp.makeConstraints { make in
            make.top.equalTo(timeLab.snp.bottom).offset(9)
            make.height.equalTo(20)
            make.width.left.equalTo(contentLab)
            make.bottom.equalTo(contentLab.snp.top).offset(10)
        }
        
        bobVc.snp.makeConstraints { make in
            make.top.equalTo(contentLab.snp.bottom).offset(-10)
            make.height.equalTo(20)
            make.width.left.equalTo(contentLab)
            make.bottom.equalToSuperview()
        }
        
        contentView.addSubview(sideVc)
        sideVc.snp.makeConstraints { make in
            make.left.equalTo(leftVc.snp.left).offset(-3)
            make.right.equalTo(rightVc.snp.right).offset(3)
            make.top.equalTo(topVc.snp.top).offset(-3)
            make.bottom.equalTo(bobVc.snp.bottom).offset(3)
        }
        
    }
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

